<?php
namespace app\admin\validate;
use think\Validate;

class Admin extends Validate
{
    protected $rule = [
        'name' => 'require|min:5|max:100',
        'type' => 'requireIf:id,>:1|number',
        'hide' => 'requireIf:id,>:1|number|in:0,1',
        'password' => 'requireIf:id,0|min:6|max:32',
        'password2' => 'requireWith:password|confirm:password',
        'city' => 'requireIf:type,3|chs',
    ];

    protected $message = [
        'name.require' => '管理员账户不能为空',
        'name.min' => '管理员账户不能小于5字符',
        'name.max' => '管理员账户不能超过100字符',
        'type.requireIf' => '权限必须填写',
        'type.number' => '权限格式错误',
        'hide.requireIf' => '账户状态必须填写',
        'hide.number' => '账户状态格式错误',
        'hide.in' => '账户状态类型错误',
        'password.requireIf' => '密码不能为空',
        'password.min' => '密码不能小于6字符',
        'password.max' => '密码不能超过32字符',
        'password2.requireWith' => '确认密码不能为空',
        'password2.confirm' => '密码与确认密码不一致',
        'city.requireIf' => '代理城市不能为空',
        'city.chs' => '代理城市格式错误',
    ];
}